package com.springbootmybatis.service.impl;

import com.springbootmybatis.dao.UserDao;
import com.springbootmybatis.entity.User;
import com.springbootmybatis.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.UUID;

@Service
public class UserServiceImpl implements UserService {

    @Resource
    UserDao userDao;

    @Override
    public User selectByUserId(String userId) {
        return userDao.selectByUserId(userId);
    }

    @Override
    public void deleteByUserId(String userId){
        userDao.deleteByUserId(userId);
    }

    @Override
    public String insert(User user) {
        String userId = UUID.randomUUID().toString().replace("-", "").toLowerCase();
        user.setUserId(userId);
        userDao.insert(user);
        return userId;
    }

    @Override
    public void update(User user) {
        userDao.update(user);
    }
}
